package com.eedi.framework.tenant.dal.mapper;

import com.eedi.framework.common.enums.CommonStatusEnum;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutCreateReq;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutResp;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupShortcutUpReq;
import com.eedi.framework.tenant.convert.SysSetupShortcutConvert;
import com.eedi.framework.tenant.dal.dataobject.SysSetupShortcutDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 系统设置
 * 快捷方式
 *
 * @author zybourn
 */
@Mapper
public interface SysSetupShortcutMapper extends BaseMapperX<SysSetupShortcutDO> {

    default void insert(SysSetupShortcutCreateReq req) {
        SysSetupShortcutDO sysSetupShortcut = SysSetupShortcutConvert.INSTANCE.convert(req);
        sysSetupShortcut.setSysSetupShortcutStatus(CommonStatusEnum.ENABLE);
        insert(sysSetupShortcut);
    }

    default void update(SysSetupShortcutUpReq req) {
        SysSetupShortcutDO sysSetupShortcut = SysSetupShortcutConvert.INSTANCE.convert(req);
        updateById(sysSetupShortcut);
    }

    default SysSetupShortcutResp getById(String sysSetupShortcutId) {
        return SysSetupShortcutConvert.INSTANCE.convert(selectById(sysSetupShortcutId));
    }

    default List<SysSetupShortcutResp> list() {
        return SysSetupShortcutConvert.INSTANCE.convert(selectList(new LambdaQueryWrapperX<SysSetupShortcutDO>().orderByAsc(SysSetupShortcutDO::getSysSetupShortcutSort)));
    }
}
